package com.jackstraw.jack_base.util.exception.enums;

/**
 * 子模块错误编码定义
 */
public enum ExceptionEnum {

    PUBLIC(ExceptionPartenEnum.GLOUB, "001"),

    UTIL(ExceptionPartenEnum.UTIL, "001-"),
    RULES(ExceptionPartenEnum.RULES, "001-"),

    APOLLO_CONFIG(ExceptionPartenEnum.CONFIG, "001-"),
    NACOS_CONFIG(ExceptionPartenEnum.CONFIG, "002-"),

    EUREKA_DISCOVERY(ExceptionPartenEnum.DISCOVERY, "001-"),
    NACOS_DISCOVERY(ExceptionPartenEnum.DISCOVERY, "002-"),
    ZOOKEEPER_DISCOVERY(ExceptionPartenEnum.DISCOVERY, "003-"),

    XXLJOB_JOB(ExceptionPartenEnum.JOB, "001-"),

    COMMON_MQ(ExceptionPartenEnum.MQ, "001-"),
    ROCKETMQ_MQ(ExceptionPartenEnum.MQ, "002-"),
    KAFKA_MQ(ExceptionPartenEnum.MQ, "003-"),

    MINIO_OSS(ExceptionPartenEnum.OSS, "001-"),

    GATEWAY_ROUTING(ExceptionPartenEnum.ROUTING, "001-"),
    OPENFEIGN_ROUTING(ExceptionPartenEnum.ROUTING, "002-"),

    REMOTE_COMMAND(ExceptionPartenEnum.REMOTE, "001-"),

    COMMON_DATASOURCE(ExceptionPartenEnum.DATASOURCE, "001-"),
    DATABASE_DATASOURCE(ExceptionPartenEnum.DATASOURCE, "002-"),
    ELASTICSEARCH_DATASOURCE(ExceptionPartenEnum.DATASOURCE, "003-"),
    REDIS_DATASOURCE(ExceptionPartenEnum.DATASOURCE, "004-"),
    ZOOKEEPER_DATASOURCE(ExceptionPartenEnum.DATASOURCE, "005-"),
    MYBATIS_DATASOURCE(ExceptionPartenEnum.DATASOURCE, "006-"),
    SEATRA_DATASOURCE(ExceptionPartenEnum.DATASOURCE, "007-"),
    JPA_DATASOURCE(ExceptionPartenEnum.DATASOURCE, "008-"),
    MYBATIS_PLUS_DATASOURCE(ExceptionPartenEnum.DATASOURCE, "009-"),

    ;


    private ExceptionPartenEnum exceptionPartenEnum;
    private String errorCode;

    ExceptionEnum(ExceptionPartenEnum exceptionPartenEnum, String errorCode) {
        this.exceptionPartenEnum = exceptionPartenEnum;
        this.errorCode = errorCode;
    }

    public ExceptionPartenEnum getExceptionPartenEnum() {
        return exceptionPartenEnum;
    }

    public String getErrorCode() {
        return errorCode;
    }

    /**
     * 得到错误编码
     *
     * @return
     */
    public String getErrorSubCode() {
        return this.getExceptionPartenEnum().getErrorPartenCode().concat(this.getErrorSubCode());
    }

    /**
     * 得到错误编码
     *
     * @return
     */
    public String getErrorSubCode(String errorSubCode) {
        return this.getExceptionPartenEnum().getErrorPartenCode().concat(this.getErrorCode().concat(errorSubCode));
    }

}
